<div class="sc_form_body">
    <form action="{$view['id']?U('save'):U('add')}?spm={$spm}" id="form" class="layui-form layui-form-pane">
        <input type="hidden" name="id" value="{$view.id|default=''}" />
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label label-required">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value="{$view.title|default=''}" placeholder="标题" datatype="*" nullmsg="请输入标题!" autocomplete="off" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序号</label>
                    <div class="layui-input-block">
                        <input type="text" name="order_id" value="{$view.order_id|default=''}" placeholder="排序号 - 数字越大越前，默认或不填为0" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea name="description" placeholder="幻灯片描述" class="layui-textarea">{$view.description|default=''}</textarea>
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label label-required">链接地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="url" value="{$view.url|default=''}" placeholder="链接地址 - 为空请输入 #" datatype="*" nullmsg="请输入链接地址" autocomplete="off" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item from_item_image">
                    <div class="img_label">
                        <label>封面图</label>
                        <a id="btn_upload_thumb"></a>
                        <span><i class="layui-icon" data-tips-text="推荐尺寸 720x720">&#xe6b2;</i></span>
                    </div>
                    <div id="thumb_view" class="img_item transition" style="background-image:url('{$view.thumb|default='__Base__/images/noimg.png'}')">
                        <img layer-src="{$view.thumb|default='__Base__/images/noimg.png'}" src="__Base__/images/alpha.png">
                        <input type="hidden" name="thumb" value="{$view.thumb|default=''}">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn">保存</button>
            </div>
        </div>
    </form>
</div>
<script>
    $(document).ready(function() {
        //图片预览
        layer.photos({photos: '#thumb_view',shade: 0.7,anim: 5});
    });
    $('#btn_upload_thumb').uploadify({
        'swf'      : '/Public/plugs/uploadify/uploadify.swf',
        'uploader' : '{:U("Uploads/upload")}',
        'multi' : false,
        'buttonClass' : '',
        'buttonText' : '本地上传',
        'width' : 110,
        'height' : 36,
        'onUploadSuccess' : function(file, data, response) {
            var allData = eval('(' + data + ')');
            if(allData.status == 1){
                $("#thumb_view").css("background-image","url("+allData.image_src+")");
                $("#thumb_view").find('img').attr('layer-src', allData.image_src);
                $("#thumb_view").find('input').val(allData.image_src);
            }else{
                var timer;
                layer.open({
                    content: allData.info,
                    closeBtn: 0,
                    icon: 2,
                    btn:[],
                    success: function(a,b){
                        var i = 1;
                        var fn = function() {
                            layer.title(i + ' 秒后自动关闭。',b);
                            if(!i) {layer.close(b); return false;} i--;
                        };
                        timer = setInterval(fn, 1000);
                        fn();
                    },
                    cancel: function(i){
                        return false;
                    },
                    end: function(){clearInterval(timer);}
                });
            }
        },
    });
</script>
